package com.wxn.learncompose.pagers

import android.widget.Toast
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import com.wxn.learncompose.MyApp

@Composable
fun  CardPager() {
    Surface {

        Column(
            modifier = Modifier.fillMaxWidth(1f)
                .padding(horizontal = 8.dp, vertical = 16.dp)
        ) {
            Spacer(modifier = Modifier.size(1.dp, 24.dp))

            Card(
                modifier = Modifier
                    .fillMaxWidth()
                    .shadow(elevation = 5.dp)
                    .background(Color.White, RoundedCornerShape(12.dp))
                    .clickable {
                        Toast
                            .makeText(MyApp.context(), "CLICK!!", Toast.LENGTH_SHORT)
                            .show()
                    },
                colors = CardDefaults.elevatedCardColors(),
            ) {
                Column(
                    verticalArrangement = Arrangement.Top,
                    horizontalAlignment = Alignment.Start,
                    modifier = Modifier.background(Color.Transparent)
                        .padding(16.dp, 12.dp)

                ) {

                    Text(text = buildAnnotatedString {
                        append("欢迎来到")
                        withStyle(SpanStyle(fontWeight = FontWeight.Bold, color= Color(0XFFEE3377))){
                            append("Compose UI")
                        }
                    })
                    Spacer(modifier = Modifier.size(1.dp, 6.dp))

                    Text(text = buildAnnotatedString {
                        append("您现在正在练习的是：")
                        withStyle(SpanStyle(fontWeight = FontWeight.ExtraBold, color =Color(0XFF330033))) {
                            append("Card")
                        }
                    })
                }
            }

        }
    }

}